<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title></title>
	<script type="text/javascript">
		console.log('one', new Date().getTime())
		var ss = [{
			"unique": "4",
			"menuTitle": "资源管理",
			"children": [{
					"unique": "4-1",
					"menuTitle": "系统设置",
				},
				{
					"unique": "4-2",
					"menuTitle": "下载管理",
					"children": [{
							"unique": "4-2-1",
							"menuTitle": "图片下载"
						},
						{
							"unique": "4-2-2",
							"menuTitle": "文件下载"
						}
					]
				}
			]
		}];
		var unique = "4-2-1";
		let strArr = []
		let objMap = {} //初始hash结构
		function strSplice(str_num) {
			if (str_num.length > 2) {
				console.log(str_num.substring(0, str_num.length - 2))
				strArr.unshift(objMap[str_num])
				strSplice(str_num.substring(0, str_num.length - 2))
			} else {
				strArr.unshift(objMap[str_num])
			}
			console.log('kkk', strArr, new Date().getTime())
			return strArr
		}

		function childLoop(arr) {
			arr.forEach(item => {
				objMap[item.unique] = item.menuTitle
				if (item.children) {
					childLoop(item.children)
				}
			});
		}
		childLoop(ss)
		console.log('objMap', objMap)
		let str = ''
		let arr=strSplice(unique)
		arr.forEach((item, index) => {
			str += item + '-'
		});
		console.log(str)
		console.log('end', new Date().getTime())
	</script>
</head>

<body>
</body>

</html>